#include "PMTtest.hh"
ClassImp(PMTtest)
		PMTtest::PMTtest() {
	//wave_valid=1;
	//Impedance=50;
	//wave1d_flag=0;
	// initialization oh histograms and Trees
	// the histogram
	hist_wf2d=new TH2F("wf2dhist","hist_wf2d",10008,0,10008,800,1230,1550);
	hist_ptc=new TH1F("ptchist","hist_ptc",10008,0,10008);
		}
		PMTtest::~PMTtest() {}


//		PMTtest::GetSigWindow(TFile *input)
		void PMTtest::Fillwf2d(vector<int> wfwave){
			for(unsigned int i=0;i<wfwave.size();i++){
				hist_wf2d->Fill(i,wfwave[i]*.12);
				}
			} 
		void PMTtest::Fillptc(float ptc){
				hist_ptc->Fill(ptc);
			} 
	float PMTtest::Calculatebsl(vector<int> wfwave){
	float sum = std::accumulate(std::begin(wfwave)+Inte_Left-70, std::begin(wfwave)+Inte_Left+15, 0.0);
//	float sum = std::accumulate(std::begin(wfwave), std::begin(wfwave)+200, 0.0);
	sum=sum/85.*0.12;
////	TH1F *hbsl=new TH1F("hbsl","hbsl",100,1406,1410);
//	TH1F *hbsl=new TH1F("hbsl","hbsl",1000,sum-2,sum+2);
////	for(unsigned int i=0;i<wfwave.size();i++){
//	for(unsigned int i=0;i<wfwave.size();i++){
//	hbsl->Fill(wfwave[i]*.12);
//	}
////	float bsl=(int)hbsl->GetMaximumBin()*0.04+1406;
////	float bsl=(int)hbsl->GetMaximumBin()*0.2+sum-10;
//	float bsl=hbsl->GetMean();
//	delete hbsl;
//	return bsl;
	return sum;
	//float bsl=0;
	//int count=0;
	//for(int i=0;i<800;i++){
	//if(abs(wfwave[i]-sum)<4){bsl+=wfwave[i];count++;}
	//}
	//if(count>0)bsl=bsl/count;
	//else bsl=sum;
	//  return bsl;
	}
